package sqlexplorer.domain.sorting;

import java.util.Comparator;

import sqlexplorer.domain.metadata.TableMetaData;

public class TableMetaDataComparator implements Comparator<TableMetaData>{
	
	private SortDirection m_sortDirection;
	
	public TableMetaDataComparator(SortDirection sortDirection){
		m_sortDirection=sortDirection;
	}
	
	@Override
	public int compare(TableMetaData o1,TableMetaData o2){
		int val=o1.getTableName().compareTo(o2.getTableName());
		
		if(m_sortDirection.equals(SortDirection.ASCENDING)){
			return val;
		}else{
			return (val*(-1));
		}
	}
}
